package com.ymatou.iapi.couponservice.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.couponservice.parameter.CheckPublicCouponBean;
import com.ymatou.iapi.couponservice.parameter.CouponInfo;
import com.ymatou.iapi.couponservice.parameter.OrderInfo;
import com.ymatou.iapi.couponservice.parameter.SellerOrderInfo;
import com.ymatou.iapi.couponservice.parameter.ShoppingInfo;
import com.ymatou.iapi.couponservice.service.CheckPublicCouponCall;
import com.ymatou.iapi.m.couponservice.parameter.CreateCouponBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.business.service.CouponServiceCallService;
import com.ymttest.business.service.CouponServiceMCallService;
import com.ymttest.database.model.YmtCoupon;
import com.ymttest.database.model.YmtCouponBatch;
import com.ymttest.database.model.YmtCouponScenario;
import com.ymttest.database.model.YmtCouponSetting;
import com.ymttest.database.model.YmtCouponValue;
import com.ymttest.database.sqlwapper.YmtCouponBatchWapper;
import com.ymttest.database.sqlwapper.YmtCouponScenarioWapper;
import com.ymttest.database.sqlwapper.YmtCouponSettingWapper;
import com.ymttest.database.sqlwapper.YmtCouponValueWapper;
import com.ymttest.database.sqlwapper.YmtCouponWapper;
import com.ymttest.utils.EnvSetup;

/**
 * 检验平台公共优惠券用例-只针对短码做的校验
 * FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_CheckPublicCoupon {
    private static CheckPublicCouponBean checkpubliccouponBean;
    private static CheckPublicCouponCall checkpubliccouponCall;
    private static int userId;

    @BeforeClass
    public static void setUp() {
        Logger.createResultFile("检验平台公共优惠券用例");
    }

    @Before
    public void caseUp() {
        checkpubliccouponBean = new CheckPublicCouponBean();
        checkpubliccouponCall = new CheckPublicCouponCall();
        userId = Integer.parseInt(EnvSetup.getData("couponBuyerId"));
    }

    @AfterClass
    public static void tearDown() {
        Logger.generateResult(checkpubliccouponCall.getOpurl());
    }

    @After
    public void caseDown() {
        Logger.end();
    }
/*
    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_001() {
        Logger.start(true, "下单优惠券检验:短码通过验证");
        try {

            ShoppingInfo shoppingInfo = setDefaultCheckpubliccouponBean();
            // ShoppingInfo shoppingInfo =
            // new CouponCallService().setDefaultShoppingInfo(userId, "164524663320238699XlqzY4Wi",
            // null);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            String couponCode = shoppingInfo.getPlatformCouponCode();

            YmtCoupon coupon = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0);
            CouponInfo couponInfo = checkpubliccouponCall.getData();

            Logger.verifyEquals(null, couponInfo.getSellerIds(), "验证返回SellerId");
            Logger.verifyEquals(couponCode, couponInfo.getCouponCode(), "验证返回SellerId");

            YmtCouponBatch batch = new YmtCouponBatchWapper().selectByPrimaryKey(coupon.getiBatchId());
            YmtCouponSetting setting =
                    new YmtCouponSettingWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
            YmtCouponValue value =
                    new YmtCouponValueWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
            YmtCouponScenario scenario =
                    new YmtCouponScenarioWapper().selectByiCouponScenarioId(setting.getiScenarioId()).get(0);

            Logger.verifyEquals(batch.getsCouponName(), couponInfo.getCouponName(), "验证返回SellerId");
            Logger.verifyEquals(0, couponInfo.getMeetAmount().compareTo(value.getFminordervalue()), "验证返回SellerId");
            Logger.verifyEquals(0, couponInfo.getDeductionAmount().compareTo(value.getFcouponvalue()), "验证返回SellerId");

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            System.out.println(formatter.format(setting.getdValidStart()));
            System.out.println(formatter.format(setting.getdValidEnd()));

            Logger.verifyEquals(true,
                    isDateEqual(formatter.format(setting.getdValidStart()), couponInfo.getStartTime()),
                    "验证返回ValidStart,期望：" + setting.getdValidStart().toString());
            Logger.verifyEquals(true,
                    isDateEqual(formatter.format(setting.getdValidEnd()), couponInfo.getEndTime()),
                    "验证返回SellerId,期望：" + setting.getdValidEnd().toString());

            Logger.verifyEquals(scenario.getIusertype(), couponInfo.getUserTypeInfo(), "验证返回SellerId");
            Logger.verifyEquals(scenario.getSsellerids(), couponInfo.getSellerIds(), "验证返回SellerId");
            Logger.verifyEquals(scenario.getSproductcategories(), couponInfo.getProductCategories(), "验证返回SellerId");
            Logger.verifyEquals(scenario.getSspecificproducts(), couponInfo.getSpecificProducts(), "验证返回SellerId");
            Logger.verifyEquals(scenario.getSproductbrands(), couponInfo.getProductBrands(), "验证返回SellerId");
            Logger.verifyEquals(scenario.getSactivityids(), couponInfo.getActivityIds(), "验证返回SellerId");
            Logger.verifyEquals(scenario.getSuseplatforms(), couponInfo.getUsePlatforms(), "验证返回SellerId");


        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_002() {
        Logger.start(false, "反例-请传入购物车订单信息-shoppingInfo == null");
        try {

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("shoppingInfo:shoppinginfo is not null", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_003() {
        Logger.start(false, "反例-请传入购物车订单信息-shoppingInfo.SellerOrderInfos == null");
        try {
            ShoppingInfo shoppingInfo = new ShoppingInfo();

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("shoppingcart is null", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_004() {
        Logger.start(false, "反例-请传入购物车订单信息-shoppingInfo.SellerOrderInfos.Count == 0");
        try {

            ShoppingInfo shoppingInfo = new ShoppingInfo();

            List<SellerOrderInfo> sellerOrderInfos = new ArrayList<SellerOrderInfo>();
            shoppingInfo.setSellerOrderInfos(sellerOrderInfos);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("shoppingcart is null", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_005() {
        Logger.start(false, "反例-请传入用户信息-shoppingInfo.BuyerInfo == null");
        try {

            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, null, null);
            shoppingInfo.BuyerInfo = null;

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("未传入买家信息", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_006() {
        Logger.start(false, "反例-请传入用户信息-shoppingInfo.BuyerInfo == null");
        try {

            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, null, null);
            
            shoppingInfo.BuyerInfo = null;

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("未传入买家信息", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_007() {
        Logger.start(false, "反例-请传入使用平台-shoppingInfo.PlatformUsage <= 0");
        try {
            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, null, null);

        	shoppingInfo.setPlatformUsage(-1);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("未传入使用平台", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_008() {
        Logger.start(false, "反例-请传入商家ID-SellerId <= 0");
        try {

            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, null, null);
            shoppingInfo.getSellerOrderInfos().get(0).setSellerId(0);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("未传入商家ID", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_009() {
        Logger.start(false, "反例-请传入商家订单信息-OrderInfos == null");
        try {

            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, null, null);
            shoppingInfo.getSellerOrderInfos().get(0).setOrderInfos(null);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("未传入商家订单信息", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_010() {
        Logger.start(false, "反例-请传入商家订单信息-OrderInfos.Count == 0");
        try {

            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, null, null);

            List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();
            shoppingInfo.getSellerOrderInfos().get(0).setOrderInfos(orderInfos);;

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("未传入商家订单信息", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_011() {
        Logger.start(false, "反例-请传入商品编号-string.IsNullOrEmpty(product.ProductCode)");
        try {

            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, null, null);

            List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();
            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
                    .setProductCode(null);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("未传入商品编号", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_012() {
        Logger.start(false, "反例-请传入商品价格-product.ProductPrice <= 0");
        try {

            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, null, null);

            List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();
            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
                    .setProductPrice(new BigDecimal(0));

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("未传入商品价格", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_013() {
        Logger.start(false, "反例-请传入商品数量-product.ProductQuantity <= 0");
        try {

            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, null, null);

            List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();
            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
                    .setProductQuantity(0);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("2", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("未传入商品数量", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_014() {
        Logger.start(false, "反例-平台短码优惠券不存在");
        try {

            String couponCode = "123456789";
            CouponServiceCallService couponCallService = new CouponServiceCallService();
            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, couponCode, null);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100100", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("优惠券不存在", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_015() {
        Logger.start(false, "反例-优惠券不是短码发放");
        try {

            int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
            CouponServiceMCallService couponCallService = new CouponServiceMCallService();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

			String batchCode = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();
            String platformcouponCode = couponCallService.receiveCouponInfo(batchCode, userId).getUserReceiveResult().getCouponCode();

            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformcouponCode, null);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100102", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("不是公共优惠券", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_CheckPublicCoupon_016() {
        Logger.start(false, "反例-不是平台优惠券");
        try {

            int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));

            CouponServiceMCallService couponCallService = new CouponServiceMCallService();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		

            String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();
            List<YmtCouponBatch> ymtCouponBatchs = new YmtCouponBatchWapper()
                    .selectBysBatchCode(batchcode2);

            String platformcouponCode =
                    couponCallService.receiveCouponInfo(ymtCouponBatchs.get(0).getsBatchCode(), userId).getUserReceiveResult().getCouponCode();

            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformcouponCode, null);


            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100102", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("不是公共优惠券", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }


    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_018() {
        Logger.start(false, "反例-优惠券已经作废");
        try {

            ShoppingInfo shoppingInfo = setDefaultCheckpubliccouponBean();
            String couponCode = shoppingInfo.getPlatformCouponCode();

            YmtCoupon coupon = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0);
            YmtCouponBatch batch = new YmtCouponBatchWapper().selectByPrimaryKey(coupon.getiBatchId());

            // 作废优惠券
            new CouponServiceMCallService().InvalidPlatformBatch(batch.getsBatchCode(),"2233","eeee");

            // 状态改为作废
            // new YmtCouponBatchWapper().setbInvalidStatus(batchCode, 1);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100105", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("优惠券已经作废", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_019() {
        Logger.start(false, "反例-优惠券有效期已经结束");
        try {

            ShoppingInfo shoppingInfo = setDefaultCheckpubliccouponBean();
            String couponCode = shoppingInfo.getPlatformCouponCode();

            Date date = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);

            new YmtCouponWapper().setdValidEnd(date, couponCode);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100106", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("优惠券已过期", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_020() {
        Logger.start(false, "反例-优惠券有效期未开始");
        try {

            ShoppingInfo shoppingInfo = setDefaultCheckpubliccouponBean();
            String couponCode = shoppingInfo.getPlatformCouponCode();

            Date date = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);

            new YmtCouponWapper().setdValidStart(date, couponCode);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100107", checkpubliccouponCall.getStatusCode1(), "验证返回StatusCode");
            Logger.verifyEquals("优惠券还未生效", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_021() {
        Logger.start(true, "反例：商品活动指定不允许使用优惠券返回指定的错误代码");
        try {

            ShoppingInfo shoppingInfo = setDefaultCheckpubliccouponBean();

            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
                    .setIsNotAllowUsePlatformCoupon(true);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100122", checkpubliccouponCall.getStatusCode1(),
                    "验证返回StatusCode");
            Logger.verifyEquals("商品活动指定不允许使用优惠券", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    
    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_022() {
        Logger.start(true, "下单优惠券检验:短码通过验证-优惠券金额校验需要减去商品满减促销后的金额-RA-2339-满足条件");
        try {

            ShoppingInfo shoppingInfo = setDefaultCheckpubliccouponBean();

            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
            	.setProductDiscountAmount(new BigDecimal(100));
            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
    			.setProductPrice(new BigDecimal(300));

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            String couponCode = shoppingInfo.getPlatformCouponCode();

            YmtCoupon coupon = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0);
            CouponInfo couponInfo = checkpubliccouponCall.getData();

            Logger.verifyEquals(null, couponInfo.getSellerIds(), "验证返回SellerId");
            Logger.verifyEquals(couponCode, couponInfo.getCouponCode(), "验证返回CouponCode");

            YmtCouponBatch batch = new YmtCouponBatchWapper().selectByPrimaryKey(coupon.getiBatchId());
            YmtCouponSetting setting =
                    new YmtCouponSettingWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
            YmtCouponValue value =
                    new YmtCouponValueWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
            YmtCouponScenario scenario =
                    new YmtCouponScenarioWapper().selectByiCouponScenarioId(setting.getiScenarioId()).get(0);

            Logger.verifyEquals(batch.getsCouponName(), couponInfo.getCouponName(), "验证返回SellerId");
            Logger.verifyEquals(0, couponInfo.getMeetAmount().compareTo(value.getFminordervalue()), "验证返回SellerId");
            Logger.verifyEquals(0, couponInfo.getDeductionAmount().compareTo(value.getFcouponvalue()), "验证返回SellerId");

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            System.out.println(formatter.format(setting.getdValidStart()));
            System.out.println(formatter.format(setting.getdValidEnd()));

            Logger.verifyEquals(true,
                    isDateEqual(formatter.format(setting.getdValidStart()), couponInfo.getStartTime()),
                    "验证返回ValidStart,期望：" + setting.getdValidStart().toString());
            Logger.verifyEquals(true,
                    isDateEqual(formatter.format(setting.getdValidEnd()), couponInfo.getEndTime()),
                    "验证返回SellerId,期望：" + setting.getdValidEnd().toString());

            Logger.verifyEquals(scenario.getIusertype(), couponInfo.getUserTypeInfo(), "验证返回UserTypeInfo");
            Logger.verifyEquals(scenario.getSsellerids(), couponInfo.getSellerIds(), "验证返回SellerId");
            Logger.verifyEquals(scenario.getSproductcategories(), couponInfo.getProductCategories(), "验证返回ProductCategories");
            Logger.verifyEquals(scenario.getSspecificproducts(), couponInfo.getSpecificProducts(), "验证返回SpecificProducts");
            Logger.verifyEquals(scenario.getSproductbrands(), couponInfo.getProductBrands(), "验证返回ProductBrands");
            Logger.verifyEquals(scenario.getSactivityids(), couponInfo.getActivityIds(), "验证返回ActivityIds");
            Logger.verifyEquals(scenario.getSuseplatforms(), couponInfo.getUsePlatforms(), "验证返回UsePlatforms");


        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    
    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_023() {
        Logger.start(true, "下单优惠券检验:短码通过验证-优惠券金额校验需要减去商品满减促销后的金额-RA-2339-不满足条件");
        try {

            ShoppingInfo shoppingInfo = setDefaultCheckpubliccouponBean();

            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
            	.setProductDiscountAmount(new BigDecimal(100));
            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
    			.setProductPrice(new BigDecimal(299));

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100116", checkpubliccouponCall.getStatusCode1(),
                    "验证返回StatusCode");
            Logger.verifyEquals("商品金额不足，不允许使用", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_024() {
        Logger.start(true, "平台短码优惠券，数量为1，单张优惠券限用数量与总使用数量相等，验证用户不可多次使用优惠券-RA-2739");
        try {

        	int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
        	CouponServiceMCallService couponCallService = new CouponServiceMCallService();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();		

            createcouponBean.setPerCouponMaxUseCount(2);
            createcouponBean.setPerUserReceiveMaxCount(1);
            createcouponBean.setCouponNum(2);
            
            // createcouponBean
            String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();


            List<YmtCouponBatch> ymtCouponBatchs = new YmtCouponBatchWapper()
                    .selectBysBatchCode(batchcode2);

            List<YmtCoupon> coupons = new YmtCouponWapper()
                    .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());

            // 由于创新短码优惠券会进调度任务，存在一定延迟，所以要等待直到相应数据进Ymt_Coupon表
            int flag = 0;
            while (coupons.size() == 0 && flag < 500)
            {
                Thread.sleep(100);
                coupons = new YmtCouponWapper()
                        .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());
                flag++;
            }

            String platformcouponCode = coupons.get(0).getsCouponCode();

            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformcouponCode, null);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

            // 使用优惠券
            new CouponServiceCallService().useCoupon(shoppingInfo.getBuyerInfo().getBuyerId(), shoppingInfo.getPlatformCouponCode());
         
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100120", checkpubliccouponCall.getStatusCode1(),
                    "验证返回StatusCode");
            Logger.verifyEquals("超出单个用户最大使用次数", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    
    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_025() {
        Logger.start(true, "平台短码优惠券，优惠券限定商品分类-类目包含验证通过，JIRACONN-954");
        try {
        	
        	int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
        	CouponServiceMCallService couponCallService = new CouponServiceMCallService();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();	
           
			List<Integer> Categories = new ArrayList<Integer>();
            Categories.add(33333);
            Categories.add(22222);

            createcouponBean.setCategories(Categories);
            
            // createcouponBean
            String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();


            List<YmtCouponBatch> ymtCouponBatchs = new YmtCouponBatchWapper()
                    .selectBysBatchCode(batchcode2);

            List<YmtCoupon> coupons = new YmtCouponWapper()
                    .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());

            // 由于创新短码优惠券会进调度任务，存在一定延迟，所以要等待直到相应数据进Ymt_Coupon表
            int flag = 0;
            while (coupons.size() == 0 && flag < 500)
            {
                Thread.sleep(100);
                coupons = new YmtCouponWapper()
                        .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());
                flag++;
            }

            String platformcouponCode = coupons.get(0).getsCouponCode();

            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformcouponCode, null);

            List<String> Categories2 = new ArrayList<String>();
            Categories2.add("22222");
            Categories2.add("44444");
            
            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
            	.setProductCategoryList(Categories2);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

             checkpubliccouponCall.setData(checkpubliccouponBean);
             checkpubliccouponCall.callService();

             String couponCode = shoppingInfo.getPlatformCouponCode();

             YmtCoupon coupon = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0);
             CouponInfo couponInfo = checkpubliccouponCall.getData();

             Logger.verifyEquals(null, couponInfo.getSellerIds(), "验证返回SellerId");
             Logger.verifyEquals(couponCode, couponInfo.getCouponCode(), "验证返回SellerId");

             YmtCouponBatch batch = new YmtCouponBatchWapper().selectByPrimaryKey(coupon.getiBatchId());
             YmtCouponSetting setting =
                     new YmtCouponSettingWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
             YmtCouponValue value =
                     new YmtCouponValueWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
             YmtCouponScenario scenario =
                     new YmtCouponScenarioWapper().selectByiCouponScenarioId(setting.getiScenarioId()).get(0);

             Logger.verifyEquals(batch.getsCouponName(), couponInfo.getCouponName(), "验证返回SellerId");
             Logger.verifyEquals(0, couponInfo.getMeetAmount().compareTo(value.getFminordervalue()), "验证返回SellerId");
             Logger.verifyEquals(0, couponInfo.getDeductionAmount().compareTo(value.getFcouponvalue()), "验证返回SellerId");

             SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

             System.out.println(formatter.format(setting.getdValidStart()));
             System.out.println(formatter.format(setting.getdValidEnd()));

             Logger.verifyEquals(true,
                     isDateEqual(formatter.format(setting.getdValidStart()), couponInfo.getStartTime()),
                     "验证返回ValidStart,期望：" + setting.getdValidStart().toString());
             Logger.verifyEquals(true,
                     isDateEqual(formatter.format(setting.getdValidEnd()), couponInfo.getEndTime()),
                     "验证返回SellerId,期望：" + setting.getdValidEnd().toString());

             Logger.verifyEquals(scenario.getIusertype(), couponInfo.getUserTypeInfo(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSsellerids(), couponInfo.getSellerIds(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSproductcategories(), couponInfo.getProductCategories(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSspecificproducts(), couponInfo.getSpecificProducts(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSproductbrands(), couponInfo.getProductBrands(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSactivityids(), couponInfo.getActivityIds(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSuseplatforms(), couponInfo.getUsePlatforms(), "验证返回SellerId");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    
    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_026() {
        Logger.start(false, "平台短码优惠券，优惠券限定商品分类-类目不包含验证不通过，JIRACONN-954");
        try {

        	int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
        	CouponServiceMCallService couponCallService = new CouponServiceMCallService();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();		

            List<Integer> Categories = new ArrayList<Integer>();
            Categories.add(33333);
            Categories.add(22222);

            createcouponBean.setCategories(Categories);
            
            // createcouponBean
            String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();


            List<YmtCouponBatch> ymtCouponBatchs = new YmtCouponBatchWapper()
                    .selectBysBatchCode(batchcode2);

            List<YmtCoupon> coupons = new YmtCouponWapper()
                    .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());

            // 由于创新短码优惠券会进调度任务，存在一定延迟，所以要等待直到相应数据进Ymt_Coupon表
            int flag = 0;
            while (coupons.size() == 0 && flag < 500)
            {
                Thread.sleep(100);
                coupons = new YmtCouponWapper()
                        .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());
                flag++;
            }

            String platformcouponCode = coupons.get(0).getsCouponCode();

            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformcouponCode, null);

            List<String> Categories2 = new ArrayList<String>();
            Categories2.add("222223");

            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
            	.setProductCategoryList(Categories2);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
 
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100113", checkpubliccouponCall.getStatusCode1(),
                    "验证返回StatusCode");
            Logger.verifyEquals("优惠券限制分类，不允许使用", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    
    
    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_027() {
        Logger.start(true, "平台短码优惠券，优惠券限定国家-国家包含验证通过，JIRACONN-3004");
        try {
        	
        	int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
        	CouponServiceMCallService couponCallService = new CouponServiceMCallService();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();		

            List<Integer> nums = new ArrayList<Integer>();
            nums.add(33333);
            nums.add(22222);

            createcouponBean.setCountrys(nums);
            
            // createcouponBean
            String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();

            List<YmtCouponBatch> ymtCouponBatchs = new YmtCouponBatchWapper()
                    .selectBysBatchCode(batchcode2);

            List<YmtCoupon> coupons = new YmtCouponWapper()
                    .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());

            // 由于创新短码优惠券会进调度任务，存在一定延迟，所以要等待直到相应数据进Ymt_Coupon表
            int flag = 0;
            while (coupons.size() == 0 && flag < 500)
            {
                Thread.sleep(100);
                coupons = new YmtCouponWapper()
                        .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());
                flag++;
            }

            String platformcouponCode = coupons.get(0).getsCouponCode();

            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformcouponCode, null);

            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
      			.setCountryId(22222);

            checkpubliccouponBean.setShoppingInfo(shoppingInfo);

             checkpubliccouponCall.setData(checkpubliccouponBean);
             checkpubliccouponCall.callService();

             String couponCode = shoppingInfo.getPlatformCouponCode();

             YmtCoupon coupon = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0);
             CouponInfo couponInfo = checkpubliccouponCall.getData();

             Logger.verifyEquals(null, couponInfo.getSellerIds(), "验证返回SellerId");
             Logger.verifyEquals(couponCode, couponInfo.getCouponCode(), "验证返回SellerId");

             YmtCouponBatch batch = new YmtCouponBatchWapper().selectByPrimaryKey(coupon.getiBatchId());
             YmtCouponSetting setting =
                     new YmtCouponSettingWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
             YmtCouponValue value =
                     new YmtCouponValueWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
             YmtCouponScenario scenario =
                     new YmtCouponScenarioWapper().selectByiCouponScenarioId(setting.getiScenarioId()).get(0);

             Logger.verifyEquals(batch.getsCouponName(), couponInfo.getCouponName(), "验证返回SellerId");
             Logger.verifyEquals(0, couponInfo.getMeetAmount().compareTo(value.getFminordervalue()), "验证返回SellerId");
             Logger.verifyEquals(0, couponInfo.getDeductionAmount().compareTo(value.getFcouponvalue()), "验证返回SellerId");

             SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

             System.out.println(formatter.format(setting.getdValidStart()));
             System.out.println(formatter.format(setting.getdValidEnd()));

             Logger.verifyEquals(true,
                     isDateEqual(formatter.format(setting.getdValidStart()), couponInfo.getStartTime()),
                     "验证返回ValidStart,期望：" + setting.getdValidStart().toString());
             Logger.verifyEquals(true,
                     isDateEqual(formatter.format(setting.getdValidEnd()), couponInfo.getEndTime()),
                     "验证返回SellerId,期望：" + setting.getdValidEnd().toString());

             Logger.verifyEquals(scenario.getIusertype(), couponInfo.getUserTypeInfo(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSsellerids(), couponInfo.getSellerIds(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSproductcategories(), couponInfo.getProductCategories(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSspecificproducts(), couponInfo.getSpecificProducts(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSproductbrands(), couponInfo.getProductBrands(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSactivityids(), couponInfo.getActivityIds(), "验证返回SellerId");
             Logger.verifyEquals(scenario.getSuseplatforms(), couponInfo.getUsePlatforms(), "验证返回SellerId");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    
    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_028() {
        Logger.start(false, "平台短码优惠券，优惠券限定国家-国家不包含验证不通过，JIRACONN-3004");
        try {

        	int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
        	CouponServiceMCallService couponCallService = new CouponServiceMCallService();

			// 平台优惠券
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();		

            List<Integer> nums = new ArrayList<Integer>();
            nums.add(33333);
            nums.add(22222);

            createcouponBean.setCountrys(nums);
            
            // createcouponBean
            String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();


            List<YmtCouponBatch> ymtCouponBatchs = new YmtCouponBatchWapper()
                    .selectBysBatchCode(batchcode2);

            List<YmtCoupon> coupons = new YmtCouponWapper()
                    .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());

            // 由于创新短码优惠券会进调度任务，存在一定延迟，所以要等待直到相应数据进Ymt_Coupon表
            int flag = 0;
            while (coupons.size() == 0 && flag < 500)
            {
                Thread.sleep(100);
                coupons = new YmtCouponWapper()
                        .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());
                flag++;
            }

            String platformcouponCode = coupons.get(0).getsCouponCode();

            ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformcouponCode, null);

            shoppingInfo.getSellerOrderInfos().get(0).getOrderInfos().get(0).getProductInfos().get(0)
  				.setCountryId(11111);
            
            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
 
            checkpubliccouponCall.setData(checkpubliccouponBean);
            checkpubliccouponCall.callService();

            Logger.verifyEquals("null", checkpubliccouponCall.getSellerId(), "验证返回SellerId");
            Logger.verifyEquals("100123", checkpubliccouponCall.getStatusCode1(),
                    "验证返回StatusCode");
            Logger.verifyEquals("优惠券限制国家，不允许使用", checkpubliccouponCall.getMessage(),
                    "验证返回Message");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    
    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_CheckPublicCoupon_029() {
        Logger.start(true, "下单优惠券检验:短码通过验证");
        try {

//            ShoppingInfo shoppingInfo = setDefaultCheckpubliccouponBean();
//            // ShoppingInfo shoppingInfo =
//            // new CouponCallService().setDefaultShoppingInfo(userId, "164524663320238699XlqzY4Wi",
//            // null);
//
//            checkpubliccouponBean.setShoppingInfo(shoppingInfo);
//            
            CouponCallService service = new CouponCallService();
            
            service.useCoupon(12334, "AKKZUS426");
//            checkpubliccouponCall.setData(checkpubliccouponBean);
//            checkpubliccouponCall.callService();
//
//            String couponCode = shoppingInfo.getPlatformCouponCode();
//
//            YmtCoupon coupon = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0);
//            CouponInfo couponInfo = checkpubliccouponCall.getData();
//
//            Logger.verifyEquals(null, couponInfo.getSellerIds(), "验证返回SellerId");
//            Logger.verifyEquals(couponCode, couponInfo.getCouponCode(), "验证返回SellerId");
//
//            YmtCouponBatch batch = new YmtCouponBatchWapper().selectByPrimaryKey(coupon.getiBatchId());
//            YmtCouponSetting setting =
//                    new YmtCouponSettingWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
//            YmtCouponValue value =
//                    new YmtCouponValueWapper().selectByiCouponSettingId(coupon.getiCouponSetting()).get(0);
//            YmtCouponScenario scenario =
//                    new YmtCouponScenarioWapper().selectByiCouponScenarioId(setting.getiScenarioId()).get(0);
//
//            Logger.verifyEquals(batch.getsCouponName(), couponInfo.getCouponName(), "验证返回SellerId");
//            Logger.verifyEquals(0, couponInfo.getMeetAmount().compareTo(value.getFminordervalue()), "验证返回SellerId");
//            Logger.verifyEquals(0, couponInfo.getDeductionAmount().compareTo(value.getFcouponvalue()), "验证返回SellerId");
//
//            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
//            System.out.println(formatter.format(setting.getdValidStart()));
//            System.out.println(formatter.format(setting.getdValidEnd()));
//
//            Logger.verifyEquals(true,
//                    isDateEqual(formatter.format(setting.getdValidStart()), couponInfo.getStartTime()),
//                    "验证返回ValidStart,期望：" + setting.getdValidStart().toString());
//            Logger.verifyEquals(true,
//                    isDateEqual(formatter.format(setting.getdValidEnd()), couponInfo.getEndTime()),
//                    "验证返回SellerId,期望：" + setting.getdValidEnd().toString());
//
//            Logger.verifyEquals(scenario.getIusertype(), couponInfo.getUserTypeInfo(), "验证返回SellerId");
//            Logger.verifyEquals(scenario.getSsellerids(), couponInfo.getSellerIds(), "验证返回SellerId");
//            Logger.verifyEquals(scenario.getSproductcategories(), couponInfo.getProductCategories(), "验证返回SellerId");
//            Logger.verifyEquals(scenario.getSspecificproducts(), couponInfo.getSpecificProducts(), "验证返回SellerId");
//            Logger.verifyEquals(scenario.getSproductbrands(), couponInfo.getProductBrands(), "验证返回SellerId");
//            Logger.verifyEquals(scenario.getSactivityids(), couponInfo.getActivityIds(), "验证返回SellerId");
//            Logger.verifyEquals(scenario.getSuseplatforms(), couponInfo.getUsePlatforms(), "验证返回SellerId");


        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    private ShoppingInfo setDefaultCheckpubliccouponBean() throws ClientProtocolException, IOException,
            InterruptedException
    {
        int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
        CouponServiceCallService couponCallService = new CouponServiceCallService();

        // 平台优惠券
        CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformShortCodeCreateCouponBean();
        // createcouponBean
        String batchcode2 = couponCallService.createPlatformCoupon(createcouponBean).getBatchCode();


        List<YmtCouponBatch> ymtCouponBatchs = new YmtCouponBatchWapper()
                .selectBysBatchCode(batchcode2);

        List<YmtCoupon> coupons = new YmtCouponWapper()
                .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());

        // 由于创新短码优惠券会进调度任务，存在一定延迟，所以要等待直到相应数据进Ymt_Coupon表
        int flag = 0;
        while (coupons.size() == 0 && flag < 500)
        {
            Thread.sleep(100);
            coupons = new YmtCouponWapper()
                    .selectByiBatchId(ymtCouponBatchs.get(0).getiBatchId());
            flag++;
        }

        String platformcouponCode = coupons.get(0).getsCouponCode();

        ShoppingInfo shoppingInfo = couponCallService.setDefaultShoppingInfo(userId, platformcouponCode, null);

        return shoppingInfo;
    }

    private boolean isDateEqual(String str1, String str2)
    {
        str1 = str1.substring(0, 18);
        str2 = str2.substring(0, 18).replace("T", " ");
        return str1.equals(str2);
    }
*/
}
